/*
+--------------------------------------------------------
+	Copyright (c) 2004-2007 WeSofts
+	JavaScript Project for wespace
+	http://www.wesofts.com
+--------------------------------------------------------
*/

/*
+--------------------------------------------------------
+	Browser list
+--------------------------------------------------------
*/
var uagent    = navigator.userAgent.toLowerCase();
var is_safari = ( (uagent.indexOf('safari') != -1) || (navigator.vendor == "Apple Computer, Inc.") );
var is_ie     = ( (uagent.indexOf('msie') != -1) && (!is_opera) && (!is_safari) && (!is_webtv) );
var is_ie4    = ( (is_ie) && (uagent.indexOf("msie 4.") != -1) );
var is_moz    = (navigator.product == 'Gecko');
var is_ns     = ( (uagent.indexOf('compatible') == -1) && (uagent.indexOf('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_safari) );
var is_ns4    = ( (is_ns) && (parseInt(navigator.appVersion) == 4) );
var is_opera  = (uagent.indexOf('opera') != -1);
var is_kon    = (uagent.indexOf('konqueror') != -1);
var is_webtv  = (uagent.indexOf('webtv') != -1);
var is_win    =  ( (uagent.indexOf("win") != -1) || (uagent.indexOf("16bit") !=- 1) );
var is_mac    = ( (uagent.indexOf("mac") != -1) || (navigator.vendor == "Apple Computer, Inc.") );
var ua_vers   = parseInt(navigator.appVersion);

if (typeof jslang == 'undefined'){
	var jslang = {}
}
/*
+--------------------------------------------------------
+	Get element by id as simple style
+--------------------------------------------------------
*/
function $(id){
	if (document.getElementById(id)){
		return document.getElementById(id);
	}else{
		return false;
	}
}
function $_(id){
	if (document.getElementById(id)){
		return document.getElementById(id);
	}else{
		return false;
	}
}
/*
+--------------------------------------------------------
+	Get element by tagname
+--------------------------------------------------------
*/
function getags(name){
	if (document.getElementsByTagName(name)){
		return document.getElementsByTagName(name);
	}else{
		var ruturns = new Array();
		return returns;
	}
}

/*
+--------------------------------------------------------
+	Create element!
+--------------------------------------------------------
*/
function CreateEvent(object,type,fn){ 
	if (object.attachEvent){ 
		object['e' + type + fn] = fn;
		object[type + fn] = function(){
			object['e' + type + fn](window.event);
		} 
		object.attachEvent('on' + type,object[type + fn]); 
	}else{
		object.addEventListener(type,fn,false); 
	}
}

/*
+--------------------------------------------------------
+	Leave Page alerm
+--------------------------------------------------------
*/
if (typeof page_leave_active == 'undefined'){
	var page_leave_active = false;
}
CreateEvent(
	window,
	'beforeunload',
	function(event){
		if (page_leave_active){
			if (typeof jslang == 'undefined' || typeof jslang.page_leave_active == 'undefined'){
				var msger = 'All the un saved data would be losed.';
			}else{
				var msger = jslang.page_leave_active;
			}
			event.returnValue = msger;
		}
	}
);

/*
+----------------------------
+	count true length
+----------------------------
*/
function wane_length( sTargetStr ) 
{ 
	var sTmpStr, sTmpChar; 
	var nOriginLen = 0; 
	var nStrLength = 0; 
	sTmpStr = new String(sTargetStr); 
	nOriginLen = sTmpStr.length; 
	for ( var i=0 ; i < nOriginLen ; i++ ) 
	{ 
		sTmpChar = sTmpStr.charAt(i); 
		if (escape(sTmpChar).length > 4) 
		{ 
			nStrLength += 2; 
		} 
		else if (sTmpChar!='\r') 
		{ 
			nStrLength ++; 
		} 
	} 
	return nStrLength; 
} 

function subop(obj){
	var tLeft = obj.offsetLeft;
	var tTop = obj.offsetTop + 38;
	while(obj=obj.offsetParent) {
		tLeft+=obj.offsetLeft;
		tTop+=obj.offsetTop;
	}
	if($_('ucmenu').style.display == 'none'){
		$_('ucmenu').style.cssText = 'display:block; left:' + tLeft + 'px; top:' + tTop + 'px;';
	}
	else{
		$_('ucmenu').style.cssText = 'display:none;';
	}
}